package homework4223;

import java.io.*;

public class Homework {
    public static void main(String[] args) {
        DataInputStream dis = null;
        DataOutputStream dos = null;

        try {
            dis = new DataInputStream(new FileInputStream("E:\\liuleiwoaini\\liuleixiaobaobei.jpg"));
            dos = new DataOutputStream(new FileOutputStream("document/copy_liuleixiaobaobei.jpg"));
            int len = 0;
            byte[] buf = new byte[1024];
            while ((len = dis.read(buf)) > 0) {
                dos.write(buf, 0, len);
                dos.flush();
            }
            System.out.println("复制二进制文件成功！");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(null != dos){
                try {
                    dos.close();
                    dos = null;
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }
        }
    }
}
